From 37dc5d9198e2a423902613a9d800d531ea2ba4e1 Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <daniel@octaforge.org>
Date: Sat, 18 Feb 2023 01:45:34 +0100
Subject: [PATCH] drop guess behavior for consoles/charmap and specify fixed
 values

This was never really reliable, as the guess behavior relies on
stuff that is not present in Chimera. Additionally, we now make
ACTIVE_CONSOLES the canonical value for default VT getty config,
so better always set it right.

Also, do not configure the font by default. Leave it to what the
kernel defaults to, unless the user wants something else.
---
 config/console-setup |  8 ++++----
 man/console-setup.5  | 17 +----------------
 setupcon             | 37 +------------------------------------
 3 files changed, 6 insertions(+), 56 deletions(-)

diff --git a/config/console-setup b/config/console-setup
index d27955c..bd20f61 100644
--- a/config/console-setup
+++ b/config/console-setup
@@ -2,13 +2,13 @@
 
 # Consult the console-setup(5) manual page.
 
-ACTIVE_CONSOLES=guess
+ACTIVE_CONSOLES="/dev/tty[1-6]"
 
-CHARMAP=guess
+CHARMAP="UTF-8"
 
 CODESET=guess
-FONTFACE=TerminusBold
-FONTSIZE=16
+FONTFACE=
+FONTSIZE=
 
 VIDEOMODE=
 
diff --git a/man/console-setup.5 b/man/console-setup.5
index 8bc515d..3135b8b 100644
--- a/man/console-setup.5
+++ b/man/console-setup.5
@@ -69,14 +69,7 @@ are allowed.  On Linux usually you can set this to
 .B /dev/tty[1-6]
 and on FreeBSD a sensible value is
 .BR /dev/ttyv[0-8] .
-You can assign to this variable also the special value
-.BR guess .
-It will cause
-.BR setupcon (1)
-to attempt to guess the active virtual consoles by looking in
-configuration files such as
-.IR /etc/inittab " and " /etc/ttys .
-This guessing is not always reliable.
+Not setting the value will leave the console unconfigured.
 
 .TP
 .B CHARMAP
@@ -111,14 +104,6 @@ Specifies the desired encoding on the console.  Valid values are:
 .BR TIS-620 " and"
 .BR VISCII .
 .hy
-The special value
-.B guess
-is also recognized in which case the system command
-.BR locale (1)
-will be used to guess the desired encoding (currently this works
-reliably only with
-.SM GNU
-libc).
 
 .TP
 .B CODESET
diff --git a/setupcon b/setupcon
index 85de539..05eb761 100755
--- a/setupcon
+++ b/setupcon
@@ -477,46 +477,11 @@ ACTIVE_CONSOLES=$(
         fi
     done
 )
-if [ -z "$ACTIVE_CONSOLES" ]; then
-    # Some crude guess
-    #  Conf. files:
-    #    BSD:        /etc/ttys
-    #    Sys V init: /etc/inittab
-    #    Upstart:    /etc/init/*
-    #  Devices:
-    #    Linux:   /dev/tty[1-9][0-9]*
-    #    FreeBSD: /dev/ttyv[0-9a-f]
-    for tty in \
-        $(cat /etc/inittab /etc/init/* /etc/ttys 2>/dev/null \
-	| grep getty \
-        | egrep '([[:blank:]]|^)tty([1-9][0-9]*|v[0-9a-f])([[:blank:]]|$)' \
-        | sed -e '/^ *#/d' \
-              -e 's/.*[[:blank:]]\(tty[1-9][0-9]*\).*/\1/' \
-              -e 's/.*[[:blank:]]\(ttyv[0-9a-f]\).*/\1/')
-    do
-        if [ -e /dev/$tty ]; then
-            ACTIVE_CONSOLES="$ACTIVE_CONSOLES /dev/$tty"
-        fi
-    done
-fi
-if [ -z "$ACTIVE_CONSOLES" ]; then
-    case "$kernel" in
-        linux) ACTIVE_CONSOLES=$(ls /dev/tty[1-6] 2>/dev/null) ;;
-        freebsd) ACTIVE_CONSOLES=$(ls /dev/ttyv[0-3] 2>/dev/null) ;;
-    esac
-    report Can not find the active virtual consoles, \
-        assuming ACTIVE_CONSOLES=\"$ACTIVE_CONSOLES\" >&2
-else
+if [ -n "$ACTIVE_CONSOLES" ]; then
     report Configuring $ACTIVE_CONSOLES
 fi
 
 # CHARMAP
-if [ "$CHARMAP" = guess -o -z "$CHARMAP" ]; then
-    CHARMAP=''
-    if which locale >/dev/null; then
-        CHARMAP=`locale charmap`
-    fi
-fi
 CHARMAP=${CHARMAP:-UTF-8}
 # FreeBSD uses ISO8859-1, GNU uses ISO-8859-1, we use the GNU names
 case "$CHARMAP" in
-- 
2.39.0

